/**
 * Created by 李伟伟 on 2017/10/16.
 */
/**
 * Created by 李伟伟 on 2017/10/16.
 */
window.onload = function () {
    var code;
    show();
}
function show() {
    var long = 4;
    code = "";
    var span1 = document.getElementById("span1");
    var arr = new Array('1','2','3','4','5','6','7','8','9','0',
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','v','z',
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
    for(var i = 0;i < long; i++){
        var m = Math.floor(Math.random()*(arr.length));
        code = code+arr[m];
    }
    if(span1){
        span1.innerHTML = code;
    }
}
function shows() {
    var str = document.getElementById("text1").value;
    var span = document.getElementById("span4");
    if(str.length < 4){
        span.innerHTML = "验证码输入不正确！";
        span.style.color="red";
    }
    else if(str != code){
        span.innerHTML="验证码输入不正确！"
        span.style.color="red";
    }
    else{
        span.innerHTML="验证码输入正确！";
        span.style.color="green";
    }
}
